<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form action="https://www.baidu.com/" method="post" onsubmit="return newCheck()">
    <p>
        <label for="uname">用户名：</label>
        <input type="text" placeholder="请输入用户名" id="uname" name="uname">
    </p>
    <p>
        <label for="pwd">密码：</label>
        <input type="password" placeholder="请输入密码" id="pwd">
    </p>
    <input type="hidden" id="jmpwd" name="password">
    <input type="submit" value="登录">
    <!--    <button type="submit">提交</button>-->
</form>
</body>
<script>
    function encryptPassword(password) {
        return window.btoa((encodeURIComponent(password)));
    }
    function oldCheck() {
        let uname = document.getElementById("uname");
        let pwd = document.getElementById("pwd");
        //这种方式虽然前端密码加密了，但是提交的瞬间密码框黑点会瞬间多出好几个
        pwd.value = encryptPassword(pwd.value)
        return true;
    }
    function newCheck() {
        let uname = document.getElementById("uname");
        let pwd = document.getElementById("pwd");
        let jmpwd = document.getElementById("jmpwd");
        //将隐藏的密码框赋值name传输过去，页面上显示的密码框name去掉，这样请求抓包看不到这个参数，并且还是正常数量的黑点，用户体验较好，安全性较高
        jmpwd.value = encryptPassword(pwd.value);
        return true;
    }
</script>
</html>